<!--清库作业统计表-->
<template>
  <Layout>
    <Form ref="queryForm" :model="dataToQuery" :label-width="120" :loading="pageStatus.baseLoading">
        <Row class="query-form" >
    		<Col span="8">
    		   <FormItem label="企业名称：" prop="companyId">
    		    <cascader-dom class="query-form-el" ref='queryOrgCascader' @setOrgInfo='setQueryCompanyName' :orgTree="true" :setCurrentName="{label:dataToQuery.companyName,value:dataToQuery.companyId}"></cascader-dom>
    		  </FormItem>
    		</Col>
            <Col span="8">
    			<FormItem label='清库方式：'>
    				<Select v-model="dataToQuery.cleanMethod" multiple>
    				    <Option v-for="item in cleanMethodList" :value="item.codingCodeId" :key="item.codingCodeId">{{  item.codingName  }}</Option>
    				</Select>
                </FormItem>
            </Col>
    		
    		<Col span="8" v-if="!switchFlag">
    		    <Button @click="switchQuery(true)" class="ivu-btn-switch" type="text">展开∨</Button>
    		    <Button @click="reset" class="ivu-btn-reset"  >重置</Button>
    		    <Button type="primary" class="ivu-btn-query"   icon="md-search"  @click="query">查询</Button>
    		</Col>
    		<Col span="8" v-else>
    		  <FormItem label="计划时间范围：" prop="month" >
    		    <DatePicker class="query-form-el" v-model="dataToQuery.monthRange" format="yyyy-MM-dd" type="daterange" placement="bottom-end" placeholder="请选择时间段"
    		                @on-change="(date) => onSelectFieldQueryDateRange(date, 'month')"></DatePicker>
    		  </FormItem>
    		</Col>
        </Row>
		<Row v-show="switchFlag" class="query-form">
			<Col span="8">
			    <FormItem label="清理储库名称：">
					<Input class="query-form-el" type="text" v-model="dataToQuery.storageName" placeholder="请输入储库名称"></Input>
			    </FormItem>
			</Col>
            <Col span="8" :offset="8">
                <Button @click="switchQuery(false)" class="ivu-btn-switch" type="text">收起∧</Button>
                <Button @click="reset" class="ivu-btn-reset">重置</Button>
                <Button class="ivu-btn-query" icon="md-search" @click="query">查询</Button>
            </Col>
        </Row>
        <Row class="query-form">
            <Col span="24">
                <Button size="large"  class="ivu-btn-add" icon="md-add"  @click="addInfo">新增</Button>
    			<Button type="primary" class="ivu-btn-add" :loading="buttonLoading" icon="md-cloud-download"  @click="exportSubmit">导出</Button>
            </Col>
        </Row>
    </Form>
    <Table ref='table' :height="tableHeight" :row-class-name="rowClassName" no-data-text="没有查询到相关数据!" @on-selection-change = 'getSelectRows' :loading='pageStatus.loading || pageStatus.baseLoading'
           border :columns="columns1"  :data="dataTable" >
    </Table>
    <Row style="margin-right:10px;">
      <Col span="24" >
        <Page style="float: right" :total="pagedata.total" :page-size="pagedata.pageSize" @on-change="pageChange" @on-page-size-change="pageSizeChange" :page-size-opts="pageSizeArray" show-total show-sizer show-elevator />
      </Col>
    </Row>
    <Modal  :title="mode == 'view' ?'清库作业统计基本信息详情':'清库作业统计基本信息'" :transfer=false :mask-closable="false" v-model="dialogShow" v-if="dataToView && dialogShow"  :width=800  class-name='limit-height-dialog'>
      <Row>
        <Col span="24">
          <Form ref="dialogForm" :class="mode === 'view'?'modal-view-detail':''" :show-message="false" :model="dataToView" :rules="mode === 'view'?{}:ruleCustom" :label-width="mode === 'view'?140:null" :label-position="mode === 'view'?'right':'top'">
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="23">
                <FormItem label='企业名称：' prop='companyId'>
                  <div v-if="mode === 'view'">{{dataToView.companyName}}</div>
                  <cascader-dom v-else ref='orgCascader' @setOrgInfo='setCompanyId' @setOrgname="setCompanyName" :orgTree="true" :currentOrgId = "dataToView.companyId"
                                :setCurrentName="{label:dataToView.companyName,value:dataToView.companyId}" ></cascader-dom>
                </FormItem>
              </Col>
            </Row>
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="11">
                <FormItem label='清理储库名称：' prop='storageName'>
                  <div v-if="mode === 'view'">{{dataToView.storageName}}</div>
                  <Input v-else class='' placeholder="请填写清理储库名称" type='text' v-model='dataToView.storageName'></Input>
                </FormItem>
              </Col>
              <Col span="11">
                <FormItem label='储库数量：' prop='storageMount'>
                  <div v-if="mode === 'view'">{{dataToView.storageMount}}</div>
                  <InputNumber v-else class="w" :min="0"  type='text' v-model='dataToView.storageMount'></InputNumber>
                </FormItem>
              </Col>
            </Row>
            <Row type="flex" justify="space-around" class="code-row-bg">
                <Col span="11">
                    <FormItem label='维修队伍：' prop='maintenanceTeam'>
                        <div v-if="mode === 'view'">{{ dataToView.maintenanceTeam=='1'? "企业内修":dataToView.maintenanceTeam=='2'?"外包队伍":''}}</div>
                        <!--<Input v-else class='' placeholder="请填写检维修内容名称" type='text' v-model='dataToView.examinationName'></Input>-->
                        <Select v-else v-model='dataToView.maintenanceTeam' placeholder="请选择维修队伍" class='query-form-el'
                                @on-change="(value) => {dataToView.teamName=null,dataToView.contractorId=null }">
                            <Option value="1">企业内修</Option>
                            <Option value="2">外包队伍</Option>
                        </Select>
                    </FormItem>
                </Col>
              <Col span="11">
                <FormItem label='清库队伍名称：' prop='teamName'>
                  <div v-if="mode === 'view'">{{dataToView.teamName}}</div>
                    <div v-else>
                        <Input class='' v-if="dataToView.maintenanceTeam=='2'" placeholder="请填写清库队伍名称" type='text' readonly @on-focus="relatedPartiesModel=true" v-model='dataToView.teamName'></Input>
                        <Input class='' v-else-if="dataToView.maintenanceTeam=='1'" placeholder="请填写清库外包队伍名称" type='text' v-model='dataToView.teamName'></Input>
                        <Input class='' v-else placeholder="请填写清库队伍名称" type='text' disabled v-model='dataToView.teamName'></Input>
                    </div>
                </FormItem>
              </Col>
            </Row>
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="11">
                  <FormItem label='计划开工时间：' prop='startDate'>
                      <div v-if="mode === 'view'">{{ renderViewDate(dataToView.startDate)}}</div>
                      <DatePicker v-else class="w" placeholder="请选择计划开工时间" v-model='dataToView.startDate' ></DatePicker>
                  </FormItem>
              </Col>
              <Col span="11">
                  <FormItem label='计划完工时间：' prop='finishDate'>
                      <div v-if="mode === 'view'">{{ renderViewDate(dataToView.finishDate) }}</div>
                      <DatePicker v-else class="w" placeholder="请选择计划完工时间" v-model='dataToView.finishDate' ></DatePicker>
                  </FormItem>
              </Col>
            </Row>
              <Row type="flex" justify="space-around" class="code-row-bg">
                  <Col span="11">
                      <FormItem label='清库方式：' prop='cleanMethod'>
                          <div v-if="mode === 'view'">{{this.cleanMethodList[dataToView.cleanMethod] && this.cleanMethodList[dataToView.cleanMethod].codingName}}</div>
                          <Select v-else class='' placeholder="请选择类别" type='text' v-model='dataToView.cleanMethod' >
                              <Option v-for="item in cleanMethodList" :value="item.codingCodeId" :key="item.codingCodeId">{{ item.codingName }}</Option>
                          </Select>
                      </FormItem>
                  </Col>
                  <Col span="11"></Col>
              </Row>
              <Row type="flex" justify="space-around" class="code-row-bg">
                  <Col span="23">
                      <FormItem v-if="mode === 'view'" label="资质与合同附件：">
                          <div v-show="dataToView.concreteCleanIdFiles.filter(t=>t.field==='1').length>0" v-for="(item,index) in dataToView.concreteCleanIdFiles.filter(t=>t.field==='1')">
                              <a @click="downloadFiles(item,index)"><span style="color: #3399ff;margin-left: 5px">{{ item.fileName }}</span></a>
                              <Progress v-show="uploadListVisible[item.id]" :percent="uploadListPercent[index]"></Progress>
                          </div>
                      </FormItem>
                      <FormItem v-else label="资质与合同附件：">
                          <div>
                              <Upload ref="upload"
                                      :before-upload="(file) => { beforeUpload1(file, 'concreteCleanId', 'concreteCleanSelect/1') }"
                                      :show-upload-list="true"
                                      :max-size="10240"
                                      multiple
                                      type="drag"
                                      :action="fileUrl">
                                  <div style="padding: 10px">
                                      <Icon type="ios-cloud-upload" size="45" style="color: #3399ff"></Icon>
                                      <p>点击将文件拖拽到这里上传</p>
                                      <!--<span style="font-size:8px;color: #797a64">支持扩展名：.rar .zip .doc .docx .pdf...</span>-->
                                  </div>
                              </Upload>
                          </div>
                          <div v-show="dataToView.concreteCleanIdFiles.filter(t=>t.field==='1').length>0" v-for="(item,index) in dataToView.concreteCleanIdFiles.filter(t=>t.field==='1')" :key='item'>
                              <a @click="downloadFiles(item,index)">{{ item.fileName }}</a>
                              <Button type="text" icon="md-trash" @click="removeFile1(item.id, 'concreteCleanId', 'concreteCleanSelect/1')" style="margin-left: 5px;margin-bottom: 3px"/>
                              <Progress v-show="uploadListVisible[item.id]" :percent="uploadListPercent[index]"></Progress>
                              <!--<Progress  v-show="filePercentVisible[index]" :percent="filePercent[index]"></Progress>-->
                          </div>
                      </FormItem>
                  </Col>
              </Row>
              <Row type="flex" justify="space-around" class="code-row-bg">
                  <Col span="23">
                      <FormItem v-if="mode === 'view'" label="安全环保协议：">
                          <div v-show="dataToView.concreteCleanIdFiles.filter(t=>t.field==='2').length>0" v-for="(item,index) in dataToView.concreteCleanIdFiles.filter(t=>t.field==='2')">
                              <a @click="downloadFiles(item,index)"><span style="color: #3399ff;margin-left: 5px">{{ item.fileName }}</span></a>
                              <Progress v-show="uploadListVisible[item.id]" :percent="uploadListPercent[index]"></Progress>
                          </div>
                      </FormItem>
                      <FormItem v-else label="安全环保协议：">
                          <div>
                              <Upload ref="upload"
                                      :before-upload="(file) => { beforeUpload1(file, 'concreteCleanId', 'concreteCleanSelect/2') }"
                                      :show-upload-list="true"
                                      :max-size="10240"
                                      multiple
                                      type="drag"
                                      :action="fileUrl">
                                  <div style="padding: 10px">
                                      <Icon type="ios-cloud-upload" size="45" style="color: #3399ff"></Icon>
                                      <p>点击将文件拖拽到这里上传</p>
                                      <!--<span style="font-size:8px;color: #797a64">支持扩展名：.rar .zip .doc .docx .pdf...</span>-->
                                  </div>
                              </Upload>
                          </div>
                          <div v-show="dataToView.concreteCleanIdFiles.filter(t=>t.field==='2').length>0" v-for="(item,index) in dataToView.concreteCleanIdFiles.filter(t=>t.field==='2')" :key='item'>
                              <a @click="downloadFiles(item,index)">{{ item.fileName }}</a>
                              <Button type="text" icon="md-trash" @click="removeFile1(item.id, 'concreteCleanId', 'concreteCleanSelect/2')" style="margin-left: 5px;margin-bottom: 3px"/>
                              <Progress v-show="uploadListVisible[item.id]" :percent="uploadListPercent[index]"></Progress>
                              <!--<Progress  v-show="filePercentVisible[index]" :percent="filePercent[index]"></Progress>-->
                          </div>
                      </FormItem>
                  </Col>
              </Row>
              <Row type="flex" justify="space-around" class="code-row-bg">
                  <Col span="23">
                      <FormItem v-if="mode === 'view'" label="施工技术方案：">
                          <div v-show="dataToView.concreteCleanIdFiles.filter(t=>t.field==='3').length>0" v-for="(item,index) in dataToView.concreteCleanIdFiles.filter(t=>t.field==='3')">
                              <a @click="downloadFiles(item,index)"><span style="color: #3399ff;margin-left: 5px">{{ item.fileName }}</span></a>
                              <Progress v-show="uploadListVisible[item.id]" :percent="uploadListPercent[index]"></Progress>
                          </div>
                      </FormItem>
                      <FormItem v-else label="施工技术方案：">
                          <div>
                              <Upload ref="upload"
                                      :before-upload="(file) => { beforeUpload1(file, 'concreteCleanId', 'concreteCleanSelect/3') }"
                                      :show-upload-list="true"
                                      :max-size="10240"
                                      multiple
                                      type="drag"
                                      :action="fileUrl">
                                  <div style="padding: 10px">
                                      <Icon type="ios-cloud-upload" size="45" style="color: #3399ff"></Icon>
                                      <p>点击将文件拖拽到这里上传</p>
                                      <!--<span style="font-size:8px;color: #797a64">支持扩展名：.rar .zip .doc .docx .pdf...</span>-->
                                  </div>
                              </Upload>
                          </div>
                          <div v-show="dataToView.concreteCleanIdFiles.filter(t=>t.field==='3').length>0" v-for="(item,index) in dataToView.concreteCleanIdFiles.filter(t=>t.field==='3')" :key='item'>
                              <a @click="downloadFiles(item,index)">{{ item.fileName }}</a>
                              <Button type="text" icon="md-trash" @click="removeFile1(item.id, 'concreteCleanId', 'concreteCleanSelect/3')" style="margin-left: 5px;margin-bottom: 3px"/>
                              <Progress v-show="uploadListVisible[item.id]" :percent="uploadListPercent[index]"></Progress>
                              <!--<Progress  v-show="filePercentVisible[index]" :percent="filePercent[index]"></Progress>-->
                          </div>
                      </FormItem>
                  </Col>
              </Row>
              <Row type="flex" justify="space-around" class="code-row-bg">
                  <Col span="23">
                      <FormItem v-if="mode === 'view'" label="安全交底与告知：">
                          <div v-show="dataToView.concreteCleanIdFiles.filter(t=>t.field==='4').length>0" v-for="(item,index) in dataToView.concreteCleanIdFiles.filter(t=>t.field==='4')">
                              <a @click="downloadFiles(item,index)"><span style="color: #3399ff;margin-left: 5px">{{ item.fileName }}</span></a>
                              <Progress v-show="uploadListVisible[item.id]" :percent="uploadListPercent[index]"></Progress>
                          </div>
                      </FormItem>
                      <FormItem v-else label="安全交底与告知：">
                          <div>
                              <Upload ref="upload"
                                      :before-upload="(file) => { beforeUpload1(file, 'concreteCleanId', 'concreteCleanSelect/4') }"
                                      :show-upload-list="true"
                                      :max-size="10240"
                                      multiple
                                      type="drag"
                                      :action="fileUrl">
                                  <div style="padding: 10px">
                                      <Icon type="ios-cloud-upload" size="45" style="color: #3399ff"></Icon>
                                      <p>点击将文件拖拽到这里上传</p>
                                      <!--<span style="font-size:8px;color: #797a64">支持扩展名：.rar .zip .doc .docx .pdf...</span>-->
                                  </div>
                              </Upload>
                          </div>
                          <div v-show="dataToView.concreteCleanIdFiles.filter(t=>t.field==='4').length>0" v-for="(item,index) in dataToView.concreteCleanIdFiles.filter(t=>t.field==='4')" :key='item'>
                              <a @click="downloadFiles(item,index)">{{ item.fileName }}</a>
                              <Button type="text" icon="md-trash" @click="removeFile1(item.id, 'concreteCleanId', 'concreteCleanSelect/4')" style="margin-left: 5px;margin-bottom: 3px"/>
                              <Progress v-show="uploadListVisible[item.id]" :percent="uploadListPercent[index]"></Progress>
                              <!--<Progress  v-show="filePercentVisible[index]" :percent="filePercent[index]"></Progress>-->
                          </div>
                      </FormItem>
                  </Col>
              </Row>
              <Row type="flex" justify="space-around" class="code-row-bg">
                  <Col span="23">
                      <FormItem v-if="mode === 'view'" label="旁站管理情况证明：">
                          <div v-show="dataToView.concreteCleanIdFiles.filter(t=>t.field==='5').length>0" v-for="(item,index) in dataToView.concreteCleanIdFiles.filter(t=>t.field==='5')">
                              <a @click="downloadFiles(item,index)"><span style="color: #3399ff;margin-left: 5px">{{ item.fileName }}</span></a>
                              <Progress v-show="uploadListVisible[item.id]" :percent="uploadListPercent[index]"></Progress>
                          </div>
                      </FormItem>
                      <FormItem v-else label="旁站管理情况证明：">
                          <div>
                              <Upload ref="upload"
                                      :before-upload="(file) => { beforeUpload1(file, 'concreteCleanId', 'concreteCleanSelect/5') }"
                                      :show-upload-list="true"
                                      :max-size="10240"
                                      multiple
                                      type="drag"
                                      :action="fileUrl">
                                  <div style="padding: 10px">
                                      <Icon type="ios-cloud-upload" size="45" style="color: #3399ff"></Icon>
                                      <p>点击将文件拖拽到这里上传</p>
                                      <!--<span style="font-size:8px;color: #797a64">支持扩展名：.rar .zip .doc .docx .pdf...</span>-->
                                  </div>
                              </Upload>
                          </div>
                          <div v-show="dataToView.concreteCleanIdFiles.filter(t=>t.field==='5').length>0" v-for="(item,index) in dataToView.concreteCleanIdFiles.filter(t=>t.field==='5')" :key='item'>
                              <a @click="downloadFiles(item,index)">{{ item.fileName }}</a>
                              <Button type="text" icon="md-trash" @click="removeFile1(item.id, 'concreteCleanId', 'concreteCleanSelect/5')" style="margin-left: 5px;margin-bottom: 3px"/>
                              <Progress v-show="uploadListVisible[item.id]" :percent="uploadListPercent[index]"></Progress>
                              <!--<Progress  v-show="filePercentVisible[index]" :percent="filePercent[index]"></Progress>-->
                          </div>
                      </FormItem>
                  </Col>
              </Row>
              <Row type="flex" justify="space-around" class="code-row-bg">
                  <Col span="23">
                      <FormItem v-if="mode === 'view'" label="属地管理检查：">
                          <div v-show="dataToView.concreteCleanIdFiles.filter(t=>t.field==='6').length>0" v-for="(item,index) in dataToView.concreteCleanIdFiles.filter(t=>t.field==='6')">
                              <a @click="downloadFiles(item,index)"><span style="color: #3399ff;margin-left: 5px">{{ item.fileName }}</span></a>
                              <Progress v-show="uploadListVisible[item.id]" :percent="uploadListPercent[index]"></Progress>
                          </div>
                      </FormItem>
                      <FormItem v-else label="属地管理检查：">
                          <div>
                              <Upload ref="upload"
                                      :before-upload="(file) => { beforeUpload1(file, 'concreteCleanId', 'concreteCleanSelect/6') }"
                                      :show-upload-list="true"
                                      :max-size="10240"
                                      multiple
                                      type="drag"
                                      :action="fileUrl">
                                  <div style="padding: 10px">
                                      <Icon type="ios-cloud-upload" size="45" style="color: #3399ff"></Icon>
                                      <p>点击将文件拖拽到这里上传</p>
                                      <!--<span style="font-size:8px;color: #797a64">支持扩展名：.rar .zip .doc .docx .pdf...</span>-->
                                  </div>
                              </Upload>
                          </div>
                          <div v-show="dataToView.concreteCleanIdFiles.filter(t=>t.field==='6').length>0" v-for="(item,index) in dataToView.concreteCleanIdFiles.filter(t=>t.field==='6')" :key='item'>
                              <a @click="downloadFiles(item,index)">{{ item.fileName }}</a>
                              <Button type="text" icon="md-trash" @click="removeFile1(item.id, 'concreteCleanId', 'concreteCleanSelect/6')" style="margin-left: 5px;margin-bottom: 3px"/>
                              <Progress v-show="uploadListVisible[item.id]" :percent="uploadListPercent[index]"></Progress>
                              <!--<Progress  v-show="filePercentVisible[index]" :percent="filePercent[index]"></Progress>-->
                          </div>
                      </FormItem>
                  </Col>
              </Row>
              <Row type="flex" justify="space-around" class="code-row-bg">
                  <Col span="23">
                      <FormItem v-if="mode === 'view'" label="安全环保监督检查：">
                          <div v-show="dataToView.concreteCleanIdFiles.filter(t=>t.field==='7').length>0" v-for="(item,index) in dataToView.concreteCleanIdFiles.filter(t=>t.field==='7')">
                              <a @click="downloadFiles(item,index)"><span style="color: #3399ff;margin-left: 5px">{{ item.fileName }}</span></a>
                              <Progress v-show="uploadListVisible[item.id]" :percent="uploadListPercent[index]"></Progress>
                          </div>
                      </FormItem>
                      <FormItem v-else label="安全环保监督检查：">
                          <div>
                              <Upload ref="upload"
                                      :before-upload="(file) => { beforeUpload1(file, 'concreteCleanId', 'concreteCleanSelect/7') }"
                                      :show-upload-list="true"
                                      :max-size="10240"
                                      multiple
                                      type="drag"
                                      :action="fileUrl">
                                  <div style="padding: 10px">
                                      <Icon type="ios-cloud-upload" size="45" style="color: #3399ff"></Icon>
                                      <p>点击将文件拖拽到这里上传</p>
                                      <!--<span style="font-size:8px;color: #797a64">支持扩展名：.rar .zip .doc .docx .pdf...</span>-->
                                  </div>
                              </Upload>
                          </div>
                          <div v-show="dataToView.concreteCleanIdFiles.filter(t=>t.field==='7').length>0" v-for="(item,index) in dataToView.concreteCleanIdFiles.filter(t=>t.field==='7')" :key='item'>
                              <a @click="downloadFiles(item,index)">{{ item.fileName }}</a>
                              <Button type="text" icon="md-trash" @click="removeFile1(item.id, 'concreteCleanId', 'concreteCleanSelect/7')" style="margin-left: 5px;margin-bottom: 3px"/>
                              <Progress v-show="uploadListVisible[item.id]" :percent="uploadListPercent[index]"></Progress>
                              <!--<Progress  v-show="filePercentVisible[index]" :percent="filePercent[index]"></Progress>-->
                          </div>
                      </FormItem>
                  </Col>
              </Row>
            <Row type="flex" justify="space-around" class="code-row-bg">
              <Col span="23">
                <FormItem label='备注：' prop='remarks'>
                  <div v-if="mode === 'view'">{{dataToView.remarks}}</div>
                  <Input v-else  type='textarea' v-model='dataToView.remarks'></Input>
                </FormItem>
              </Col>
            </Row>
          </Form>
        </Col>
          <Modal :mask-closable="false" :transfer=false footer-hide v-model="relatedPartiesModel" :width=900 title="相关方台账" @on-cancel="relatedPartiesModel=false">
              <interested-parties-book v-if="relatedPartiesModel" v-show="relatedPartiesModel" :modelSelect="relatedPartiesModel"
                                       :companyId="dataToView.companyId"  @getSelectModelData='getSelectCount'></interested-parties-book>
          </Modal>
      </Row>
      <div slot="footer">
        <Button v-if="mode != 'view'" type="primary"  class='ivu-btn-save' @click="submit('dialogForm')" >确定</Button>
        <Button v-if="mode != 'view'" type="primary"  class='ivu-btn-cancel' @click="handleCancel" >取消</Button>
        <Button v-if="mode === 'view'" class='ivu-btn-save' @click="dialogShow=false">关闭</Button>
      </div>
    </Modal>
  </Layout>
</template>

<script>
import {Api} from '@/api/index.js'
import {sessionStorage} from '@/common/cacheUtils.js';
import {formatDate} from '@/tools/index'
var cascaderDom = () => import('@/components/cascader-dom.vue');
import pageCommonFunction from '@/components/pageCommonFunction.js'
import interestedPartiesBook from '../interestedPartiesManager/interestedPartiesBook'

export default {
    components: {cascaderDom, interestedPartiesBook},
  data(){
    return{
      ...this.createCommonDataField(),
	  // cleanMethod:'',
	  cleanMethodList: [],
	  cleanMethod:[],
      columns1: [
        { title: '序号', width: 80, fixed: 'left', align: 'center', render: (h, params) => {
            if(params.row.id === '-1') return h('span', "汇总");
            return h('span', (params.index - 1) + (this.pagedata.currentPage - 1) * this.pagedata.pageSize + 1);
          }},
        { key:'companyName',title: '企业名称',  align: 'center',fixed: 'left', width: 260 },
        { key:'storageName',title: '清理储库名称',  align: 'center', width: 200},
		{ key:'cleanMethod',title: '清库方式',  align: 'center', width: 120,render:(h, params)=>{
		  return h('span', this.cleanMethodList && this.cleanMethodList[params.row.cleanMethod] && this.cleanMethodList[params.row.cleanMethod].codingName)
		}, },
        { pattern: /^([0-9][0-9]*)?$/, key: 'storageMount', title: '储库数量', align: 'center', width: 130 },
          { key:'maintenanceTeam',title: '维修队伍',  align: 'center', width: 160,
              render:(h, params)=>{return h('span',params.row.maintenanceTeam=='1'? "企业内修":params.row.maintenanceTeam=='2'?"外包队伍":'')} },
        { key:'teamName',title: '清库队伍名称',  align: 'center', width: 160 },
        { key:'startDate',title: '计划开工时间',  align: 'center',width: 200, render: this.renderCellDate },
        { key:'finishDate',title: '计划完工时间',  align: 'center', width: 200, render: this.renderCellDate },
        { key:'remarks',title: '备注',  align: 'center', width: 150, tooltip:true },
        this.getActionColumns((params) => {
          return params.row.id === '-1';
        }),
      ],
      ruleCustom : {
        companyId: [ { required: true, message: '请填写企业名称', trigger: 'change' } ],
        storageName: [ { required: true, message: '请填写清理储库名称', trigger: 'change' } ],
		storageMount: [ { pattern: /^([0-9][0-9]*)?$/, required: true, message: '请填写储库数量,必须为数字', trigger: 'change, blur',type: 'number'}],
          maintenanceTeam: [ { required: true, message: '请填写维修队伍', trigger: 'change' } ],
		teamName: [ { required: true, message: '请填写清库外包队伍名称', trigger: 'change' } ],
		cleanMethod: [ { required: true, message: '请选择清库方式', trigger: 'change' }],
		startDate: [ { required: true, message: '请选择计划开工时间', trigger: 'change',type:'date' }],
		finishDate: [ { required: true, message: '请选择计划完工时间', trigger: 'change',type:'date' }],
      },
      tableHeight:10,
      // api
      queryUrl:Api.queryCleanRecords,
      exportUrl:Api.exportCleanRecords,
      deleteUrl:Api.deleteCleanRecords,
      updateUrl:Api.updateCleanRecords,
      saveUrl:Api.saveCleanRecords,
        buttonLoading:false,

        relatedPartiesModel:false,
    }
  },
  async mounted() {
      this.setTableHeight();
      this.pageStatus.baseLoading = true
      await this.$http.get(Api.queryCodeDetailBySortId + '/CCP-000001', {params: {}}).then((res) => {
          this.cleanMethodList = this.dictListToMap(res.data.data);
      });
      this.pageStatus.baseLoading = false
    this.query();
  },
  methods:{
    ...pageCommonFunction,
      getSelectCount(row) {
          this.$set(this.dataToView,'contractor_id', row.bookId)
          this.dataToView.teamName = row.contractorName;
          this.relatedPartiesModel = false;
      },

    beforeEditDialogOpen(data){
		data.row = data.row
    },
    deleteData(params) {
        params.row.id = params.row.concreteCleanId
      this.deleteDateAjax(params);
    },
    query() {
	  this.dataToQuery.orgId = sessionStorage('userId').getObject('userId').companyId
      this.queryAjax();
    },
    submit(name) {
        if(this.dataToView.storageMount == '')  this.dataToView.storageMount = 0;
		if(this.dataToView.startDate !="" && this.dataToView.finishDate!=""){
			if(this.dataToView.startDate.getTime()>this.dataToView.finishDate.getTime()){
				this.$Message.error("计划开工时间不应晚于计划完工时间");
			}else{
				this.submitAjax(name);
			}
		}else{
			this.submitAjax(name);
		}
    },
    createEmptyDataToAdd(){
      return {
        storageName:'',
        storageMount:1,
        teamName:'',
        cleanMethod:'',
        startDate:'',
        finishDate:'',
          concreteCleanId: this.get_uuid(),
          concreteCleanIdFiles: [],
      }
    },
      async afterDataToViewInit() {
          await this.getFiles1('concreteCleanId','concreteCleanSelect');
      },
	exportSubmit() {
        this.dataToQuery.orgId = sessionStorage('userId').getObject('userId').companyId
        if (!this.dataToQuery.cleanMethod || this.dataToQuery.cleanMethod.length < 1) {
            this.$delete(this.dataToQuery,'cleanMethod')
        }
        this.exportFormSubmit();
	},
  },
  watch:{
  },
}
</script>

<style lang='css' scoped>
	@import '../../../index.css';
</style>
